package com.ChenYaRou.www.controller;

import com.ChenYaRou.www.constant.JsonBeanConstant;
import com.ChenYaRou.www.dao.ShopDao;
import com.ChenYaRou.www.dao.UserDao;
import com.ChenYaRou.www.dao.impl.ShopDaoImpl;
import com.ChenYaRou.www.dao.impl.UserDaoImpl;
import com.ChenYaRou.www.po.Shop;
import com.ChenYaRou.www.po.User;
import com.ChenYaRou.www.utils.JsonBean;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName BanServletController
 * @Description TODO
 * @Author 86183
 * @Date 2022/5/10 17:11
 * @Version 1.0
 **/
public class BanServletController {
    /**
     * 获得所有用户和店铺
     * @return
     */
    public String getAllUserAndShop(){
        try {
            List<Object> list=new ArrayList<>();
            UserDao userDao=new UserDaoImpl();
            List<User> users = userDao.selectAll();
            ShopDao shopDao=new ShopDaoImpl();
            List<Shop> shops = shopDao.selectAll(new Shop());
            list.add(users);
            list.add(shops);
            return JsonBean.operateList(JsonBeanConstant.NULL,list);
        } catch (SQLException | NoSuchFieldException | InstantiationException | IllegalAccessException e) {
            e.printStackTrace();
        }
        return null;
    }
}
